<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }

    public function settimeAction()
    {
    $this->getHelper('viewRenderer')->setNoRender();
    $this->_helper->layout->setLayout('zerolayout');
        if ($this->getRequest()->isPost()) {
            $model = new Model_DbTable_Time();
             $id=   $model->setTime($this->getRequest());
            // echo $id;
             echo "Az időpont rögzítve lett.";
        }
        else {
            //echo 0;
            echo "Hiba történt az adat mentésekor.";
        }
    }


        public function gettimeAction()
    {
    $this->getHelper('viewRenderer')->setNoRender();
   $this->_helper->layout->setLayout('zerolayout');

            $model = new Model_DbTable_Time();
             $rows=   $model->getTime();
            //var_dump($rows->toArray());
            $rowsArr= $rows->toArray();

            //  allDay-nek boolean típusúnak kell lenni.
            foreach ($rowsArr as &$value) {
            $value['allDay']=0;
            }
            //echo json_encode($rows->toArray());
            echo json_encode($rowsArr);

    }


    public function jsontestAction()
    {
 $this->getHelper('viewRenderer')->setNoRender();
 $this->_helper->layout->setLayout('zerolayout');
// action body
        $year = date('Y');
	$month = date('m');
        $date=date('Y-m-d');

	echo json_encode(array(

		/*array(
			'id' => 111,
			'title' => "Event1",
			'start' => "$year-$month-10",
			'url' => "http://yahoo.com/"
		),

		array(
			'id' => 222,
			'title' => "Event2",
			'start' => "$year-$month-20",
			'end' => "$year-$month-22",
			'url' => "http://yahoo.com/"
		),

            array(
                        //time format :  	YY "-" MM "-" DD " " HH ":" II ":" SS
			'title' => "Test",
			'start' => "2011-02-01 16:15:00",
			'end' => "2011-02-01 17:20:00",
                         'allDay' =>false

		),*/
          array(
			'title' => "Test 2",
			'start' => "2011-02-02 19:15:00",
			'end' => "2011-02-02 20:20:00",
                         'allDay' =>0

		)

	));
    }


}

